using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Services;
using System.Web.Services.Description;
using System.CodeDom;
using System.CodeDom.Compiler;

namespace ServiceDescriptionSample
{
    class Program
    {
        static void Main(string[] args)
        {
            ServiceDescription description = ServiceDescription.Read("WsComplex.wsdl");
            ServiceDescriptionImporter importer = new ServiceDescriptionImporter();

            importer.AddServiceDescription(description, string.Empty, string.Empty);

            Console.WriteLine("Importing {0} service description with {1} associated schemas."
                , importer.ServiceDescriptions.Count, importer.Schemas.Count);

            importer.Style = ServiceDescriptionImportStyle.Client;
            importer.CodeGenerationOptions = System.Xml.Serialization.CodeGenerationOptions.GenerateProperties;

            CodeNamespace nmspace = new CodeNamespace();
            CodeCompileUnit compileUnit = new CodeCompileUnit();
            compileUnit.Namespaces.Add(nmspace);

            ServiceDescriptionImportWarnings warnings = importer.Import(nmspace, compileUnit);

            CodeDomProvider provider = CodeDomProvider.CreateProvider("CSharp");
            provider.GenerateCodeFromCompileUnit(compileUnit, Console.Out, new CodeGeneratorOptions());
        }
    }
}
